package com.proyecto.core.vista.echo.componentes;

import java.util.ResourceBundle;

import nextapp.echo2.app.Row;
import nextapp.echo2.app.SelectField;
import nextapp.echo2.app.TextField;
import nextapp.echo2.app.Extent;
import nextapp.echo2.app.event.ActionEvent;
import nextapp.echo2.app.event.ActionListener;

public class RwHora extends Row {

	private ResourceBundle resourceBundle;
	private SelectField slctHora;
	private SelectField slctMinuto;
	private SelectField slctSegundo;
	private TextField txtHoraCompleta;
	public String datoHora="00:00:00";

	/**
	 * Creates a new <code>RwHora</code>.
	 */
	public RwHora() {
		super();

		// Add design-time configured components.
		initComponents();
		cargarCompos();
	}

	private void cargarCompos(){

		String[] etiquetasH = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"};
		String[] valoresH = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"};

		String[] etiquetasM = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
		String[] valoresM = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};

		String[] etiquetasS = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
		String[] valoresS = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
		
		UtilSelectField .cargarSelectField(slctHora, etiquetasH, valoresH);
		UtilSelectField .cargarSelectField(slctMinuto, etiquetasM, valoresM);
		UtilSelectField .cargarSelectField(slctSegundo, etiquetasS, valoresS);
		
		slctHora.setSelectedIndex(0);
		slctMinuto.setSelectedIndex(0);
		slctSegundo.setSelectedIndex(0);
	}

	private void capturaDatoAction(ActionEvent e) {
		//TODO Implement.
		System.out.println(e.getSource());
		if(e.getSource() == "slctHora"){
			System.out.println("Ingersa en slctHora");
		}
		if(e.getSource() == "slctMinuto"){
			System.out.println("Ingersa en slctMinuto");

		}
		if(e.getSource() == "slctSegundo"){
			System.out.println("Ingersa en slctSegundo");
			
		}

		System.out.println(slctHora.getSelectedItem());
		System.out.println(slctMinuto.getSelectedItem());
		System.out.println(slctSegundo.getSelectedItem());
		String Hora = slctHora.getSelectedItem() + ":" + slctMinuto.getSelectedItem() + ":" + slctSegundo.getSelectedItem();
		txtHoraCompleta.setText(Hora);
		datoHora = Hora;
	}
	
	public String getDatoHora() {
		return datoHora;
	}

	public void setDatoHora(String datoHora) {
		this.datoHora = datoHora;
	}

	/**
	 * Configures initial state of component.
	 * WARNING: AUTO-GENERATED METHOD.
	 * Contents will be overwritten.
	 */
	private void initComponents() {
		slctHora = new SelectField();
		slctHora.setWidth(new Extent(50, Extent.PX));
		slctHora.setToolTipText("Hora");
		slctHora.setStyleName("2OpenLabs.SelectField.Default");
		slctHora.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				capturaDatoAction(e);
			}
		});
		add(slctHora);
		slctMinuto = new SelectField();
		slctMinuto.setWidth(new Extent(50, Extent.PX));
		slctMinuto.setToolTipText("Minuto");
		slctMinuto.setStyleName("2OpenLabs.SelectField.Default");
		slctMinuto.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				capturaDatoAction(e);
			}
		});
		add(slctMinuto);
		slctSegundo = new SelectField();
		slctSegundo.setWidth(new Extent(50, Extent.PX));
		slctSegundo.setToolTipText("Segundo");
		slctSegundo.setStyleName("2OpenLabs.SelectField.Default");
		slctSegundo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				capturaDatoAction(e);
			}
		});
		add(slctSegundo);
		txtHoraCompleta = new TextField();
		txtHoraCompleta.setWidth(new Extent(80, Extent.PX));
		txtHoraCompleta.setEnabled(false);
		txtHoraCompleta.setStyleName("2OpenLabs.TextField.Campo");
		add(txtHoraCompleta);
	}

	
}
